<?php

namespace App\Http\Repository;

use Illuminate\Support\Facades\DB;
use App\VideoChannel;
class VideoChannelRepository
{
    public function getListByVideoChannelCategoryName(string $video_channel_categroy_name, int $limit = 15)
    {
        $paginate = DB::table('video_channels as vc')
            ->leftJoin('video_channel_categorys as vcc',
                'vc.video_channel_category_id',
                '=',
                'vcc.id')
            ->where('vcc.name', $video_channel_categroy_name)
            ->select([
                "vc.name",
                "vc.id",
                "vc.updated_at",
                "vc.pic_url",
                "vc.desc",
                "vcc.name as video_channel_category_name"
            ])
            ->orderBy('vc.updated_at', 'desc')
            ->paginate($limit);

        return $paginate;
    }

    public function show(int $id)
    {
        return VideoChannel::find($id);
    }
}
